import request from "./request";
import mockRequest from './mockRequest'

export const reqConditionList = ()=>{
    return mockRequest({
        url:'/condition',
        method:'get'
    })
}

export const reqAddRole = (params)=>{
    return request({
        url:'/role',
        method:'post',
        data:params
    })
}

//获取筛选后的角色列表
export const reqGetSelectedRoles = (conditions)=>{
    return request({
        url:'/roles',
        method:'get',
        params:conditions
    })
}

//获取轮播图图片
export const reqGetBannerList = ()=> mockRequest({url:'/banner',method:'get'})

//获取所有角色信息
export const reqGetAllRoles = ()=> request({url:'/roles',method:'get'})

//删除指定id角色
export const reqDeleteARoleById = (_id)=> request({url:'/role',method:'delete',data:_id})

//依据name搜索对应角色
export const reqSearchByName = (name)=> request({url:'/roles',method:'get',params:name})

//依据id修改角色信息
export const reqUpdateRoleInfo = (_id,updateInfo)=>request({url:'/role',method:'put',data:{_id,updateInfo}})

//按分页要求查询对应角色信息
export const reqFindRolesForPagination = (pageNo,pageSize)=>request({url:'/roles/pagination',method:'get',params:{pageNo,pageSize}})
//以下均为用户管理相关API
//上传用户信息到服务端（注册）
export const reqRegister = (userInfo)=> request({url:'/register',method:'post',data:userInfo})

//登录
export const reqLogin = (loginForm)=>request({url:'/login',method:'post',data:loginForm})

//通过cookie获取用户信息
export const reqGetUserInfoByCookie = ()=>request({url:'/user',method:'get'})

//退出登录
export const reqLogout = ()=>request({url:'/logout',method:'get'})

//修改用户信息
export const reqUpdateUserInfo = (updatedInfo)=>request({url:'/user',method:'put',data:updatedInfo})

//上传用户头像
export const reqUploadAvatar = (formData)=>request({url:'/upload/avatar',method:'post',data:formData,headers: { "Content-Type": "multipart/form-data" }})